import type { RouteLocationNormalized } from 'vue-router'
import { logApi } from '@/api/modules/log/log'
import router from '@/router'

export const log = {
  /**
   * 记录菜单进入的日志
   * @param param0
   */
  menu({ fullPath, meta }: RouteLocationNormalized) {
    logApi.create({ menuUrl: fullPath, menuName: meta?.title as string, logType: 'menu' })
  },

  /**
   * 记录方法操作日志
   * @param action
   */
  action(action: string) {
    const route = router.currentRoute.value
    logApi.create({ menuUrl: route.fullPath, menuName: route?.meta?.title as string, action, logType: 'action' })
  }
}
